import  {defineStore} from 'pinia'
import axios from "axios";
import { nanoid } from "nanoid";

export const useTalkStore = defineStore('talk',{
    actions:{
        async getATalk(){
            let result = await axios.get('https://api.uomg.com/api/rand.qinghua?format=json');
            let obj = {id:nanoid(),title:result.data.content}
            this.talkList.unshift(obj)
        }
    },
    //真正存储数据的地方
    state(){
        return {
            talkList:[
                {id:'001',title:'001'},
                {id:'002',title:'002'},
                {id:'003',title:'003'}
            ]
    }
} })